package org.jetnuke.modules.weblinks;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.ActionForward;
import org.jetnuke.common.IAction;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IModuleInfo;
import org.jetnuke.common.IUserInfo;
import org.jetnuke.dao.DataAccessDriver;
import org.jetnuke.entities.LinksModRequest;
import org.jetnuke.util.JetUtil;

public class ModifyLinkRequest implements IAction {
	int lid;

	String title, name, url, description;

	int cat;

	public void setCat(int cat) {
		this.cat = cat;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setLid(int lid) {
		this.lid = lid;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IAction#exec(javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse,
	 *      org.apache.velocity.VelocityContext, org.jetnuke.common.IModuleInfo,
	 *      java.lang.String, org.jetnuke.common.IUserInfo,
	 *      org.jetnuke.common.IAdminInfo)
	 */
	public ActionForward exec(HttpServletRequest request,
			HttpServletResponse response, VelocityContext vc, IModuleInfo info,
			String op, IUserInfo ui, IAdminInfo ai) throws Exception {
		LinksModRequest modRequest = new LinksModRequest();
		modRequest.setLID(lid);
		modRequest.setDESCRIPTION(description);
		modRequest.setTITLE(title);
		modRequest.setURL(url);
		modRequest.setCID(cat);
		String user = "";
		if (ui != null)
			user = ui.getUname();
		modRequest.setMODIFYSUBMITTER(user);
		modRequest.setBROKENLINK(0);
		DataAccessDriver.getInst().newLinkModRequestDAO().addNew(modRequest);
		JetUtil.redirect(vc,response,request.getContextPath()+"/do/web_links/mod_requested");
		return null;
	}

}
